//
//  MqForumMainModuleCell.m
//  Meiqi
//
//  Created by lanou on 16/1/17.
//  Copyright © 2016年 KFC. All rights reserved.
//

#import "MqForumMainModuleCell.h"

@implementation MqForumMainModuleCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        _subjectLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, kScreenWidth, 20)];
//        _subjectLabel.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_subjectLabel];
        
        _msginfosLabel = [[UILabel alloc] initWithFrame:CGRectMake(_subjectLabel.left, _subjectLabel.bottom + 10, kScreenWidth - 20, 50)];
        _msginfosLabel.numberOfLines = 0;
//        _msginfosLabel.backgroundColor = [UIColor blueColor];
        [self.contentView addSubview:_msginfosLabel];
        
        _authorLLabel = [[UILabel alloc] initWithFrame:CGRectMake(_msginfosLabel.left, _msginfosLabel.bottom + 10, kScreenWidth / 4, 10)];
//        _authorLLabel.backgroundColor = [UIColor yellowColor];
        _authorLLabel.font = [UIFont systemFontOfSize:12];
        [self.contentView addSubview:_authorLLabel];
        
        _datelineLabel = [[UILabel alloc] initWithFrame:CGRectMake(kScreenWidth - 10 - kScreenWidth / 4, _authorLLabel.top, _authorLLabel.width, 10)];
        _datelineLabel.textAlignment = NSTextAlignmentLeft;
//        _datelineLabel.backgroundColor = [UIColor greenColor];
        _datelineLabel.font = [UIFont systemFontOfSize:12];
        [self.contentView addSubview:_datelineLabel];
        
    }
    
    return self;
    
}

- (void)setMainModule:(MqForumMainModule *)mainModule{
    
    _mainModule = mainModule;
    
    if (mainModule.coverpath != nil) {
        
        _msginfosLabel.frame = CGRectMake(_subjectLabel.left, _subjectLabel.bottom + 10, (kScreenWidth - 20) / 4 * 3, 60);
        
        UIImageView *imageV = [[UIImageView alloc] initWithFrame:CGRectMake(_msginfosLabel.right + 10, _msginfosLabel.top, _msginfosLabel.width / 3 - 10, 60)];
        
        NSString *imgPath = [NSString stringWithFormat:@"http://bbs.biketo.com/%@", mainModule.coverpath];
        
        imageV.backgroundColor = [UIColor redColor];
        [imageV sd_setImageWithURL:[NSURL URLWithString:imgPath] placeholderImage:nil];
        
        [self.contentView addSubview:imageV];
        
        
    }else{
           _msginfosLabel.frame = CGRectMake(_subjectLabel.left, _subjectLabel.bottom + 10, kScreenWidth - 20, 60);
        
    }
    
    _subjectLabel.text = mainModule.subject;
    _msginfosLabel.text = mainModule.msginfos;
    _authorLLabel.text = mainModule.author;
    _datelineLabel.text = mainModule.dateline;
    
}



@end
